# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=python_ics
pkgbase=mingw-w64-python2-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=3.1
pkgrel=1
pkgdesc="Python C Code module for interfacing to the icsneo40 dynamic library (mingw-w64)"
arch=('any')
url='https://github.com/intrepidcs/python_ics/'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python2")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/intrepidcs/python_ics/archive/${pkgver}.tar.gz"
        mingw-build.patch)
sha512sums=('d2437950c77a4bf0f77d632bb04ce23e1cb6b8a19708d9ba0c01a5f0729fb17bce11b8037db959d08b0c9a9ed5471e49a1ad39e0db448146003576afd6325f61'
            '3c8622868fc017ca8d7f4ceb7ab7bfd4e2bfb6cc9be437f0a923b02d525fa23e3349990b5dc055e04a47be79a01ecdcd6358b7169d6e4f23cbaa7e47425b3bd5')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/mingw-build.patch

  cd "${srcdir}"
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"
}

build() {
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  #install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE.txt"
}
